package com.javaweb.homework;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author: XiangHu
 * @date: 2025年02月27日  19:10
 * @describe:
 */
@WebServlet("/searchStu")
public class test extends HttpServlet {
    // 查看学生
    public static List showStu() {
        List<Stu> list = JDBCUtils.query(Stu.class, "select * from stu");
        return list;
    }

    // 处理get请求
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 设置请求编码
        req.setCharacterEncoding("UTF-8");
        // 设置响应编码
        resp.setCharacterEncoding("UTF-8");
        resp.getWriter().print(showStu());
    }
}
